package schema

import (
	"entgo.io/ent"
	"entgo.io/ent/dialect/entsql"
	"entgo.io/ent/schema"
	"entgo.io/ent/schema/field"
	"entgo.io/ent/schema/index"
	"private-domain-overseas-service/pkg/status/bizuser"
	"time"
)

// HzUser holds the schema definition for the HzUser entity.
type HzUser struct {
	ent.Schema
}

// Fields of the HzUser.
func (HzUser) Fields() []ent.Field {
	return []ent.Field{
		//field.String("user_national_domain").NotEmpty().Comment("用户国际域名"),
		field.String("user_phone").NotEmpty().Comment("用户手机号"),
		field.String("user_email").Optional().Comment("用户邮箱"),
		field.String("user_password").MaxLen(500).Optional().Comment("用户密码"),
		field.String("user_invite_code").Optional().Comment("用户邀请码"),
		field.String("user_superiors_invite_code").Optional().Comment("用户上级邀请码"),
		field.Int64("user_status").Default(bizuser.Enabled).Comment("用户状态，1、启用，2、禁用"),
		field.Int64("user_type").Default(bizuser.OrdinaryUser).Comment("用户类型，1、普通用户，2、测试用户"),
		field.String("user_register_ip_address").NotEmpty().Comment("用户注册ip地址"),
		field.Int64("created_at").Immutable().Default(time.Now().Unix()).Comment("创建时间"),
		field.Int64("update_at").Default(time.Now().Unix()).Comment("更新时间"),
		field.Int64("delete_at").Optional().Comment("删除时间"),
	}
}

// Indexes of the Street.
func (HzUser) Indexes() []ent.Index {
	return []ent.Index{
		index.Fields("user_phone").Unique(),
		index.Fields("user_email").Unique(),
		index.Fields("user_invite_code").Unique(),
		index.Fields("user_superiors_invite_code"),
	}
}

func (HzUser) Annotations() []schema.Annotation {
	return []schema.Annotation{
		entsql.WithComments(true),
		schema.Comment("用户表"),
	}
}
